package multidraw.model.commands;

import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class WrapperCommand extends Command {
	protected byte[] data;
	
	public WrapperCommand(Command cmd) throws IOException {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		ObjectOutputStream oos = new ObjectOutputStream(baos);
		
		oos.writeObject(cmd);
		
		oos.close();
		data = baos.toByteArray();
	}

	@Override
	public void execute() {
		// TODO Auto-generated method stub
		if (canvas != null) {
			canvas.applyWrapperCommand(this);
		}
	}
	
	public byte[] getData() {
		return data;
	}
}
